/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.util.HashMap;
import java.util.Map;
import libCore.Util;
import libCore.Config;
import share.ShareMacros;

/**
 *
 * @author LinhTA
 */
public class User implements EntityBase {

    public String cotes;
    public String friends;
    public String items;
    public int level;
    public int fish;
    public int gold;
    public int coin;
    public int exp;
    public long timeLogin;
    public String name;
    public String avata;
    public int helpFood;
    public int helpDay;

    @Override
    public Map<String, Object> toAMF() {
        Map<String, Object> data = new HashMap<String, Object>();

        return data;
    }

    @Override
    public void setData(Map<String, Object> obj) {
        Map<String, Object> data = Util.obj2Map(obj);
    }

    public void setUser(Map<String, String> obj) {

        cotes   =   obj.get( ShareMacros.COTES );
        friends =   obj.get( ShareMacros.FRIENDS );
        items   =   obj.get( ShareMacros.ITEMS );
        
        level   =   Integer.parseInt(obj.get(ShareMacros.LEVEL));
        fish    =   Integer.parseInt(obj.get(ShareMacros.FISH));
        gold    =   Integer.parseInt(obj.get(ShareMacros.GOLD));
        coin    =   Integer.parseInt(obj.get(ShareMacros.COIN));
        exp     =   Integer.parseInt(obj.get(ShareMacros.EXP));
        timeLogin = Long.parseLong(obj.get(ShareMacros.TIMELOGIN));
        helpFood =  Integer.parseInt(obj.get(ShareMacros.USER_HELPFOOD));
        avata   =   obj.get(ShareMacros.USER_AVATA);
        name    =   obj.get(ShareMacros.USER_NAME);
        helpDay =   Integer.parseInt(obj.get(ShareMacros.USER_HELPDAY));
    }

    public void setDefaultData(String kcotes, String kfriends, String uName, String uAvata) {
        cotes       =   kcotes;
        friends     =   kfriends;
        level       =   Integer.parseInt(Config.getParam("defaultUser", "level"));
        fish        =   Integer.parseInt(Config.getParam("defaultUser", "food"));
        gold        =   Integer.parseInt(Config.getParam("defaultUser", "gold"));
        coin        =   Integer.parseInt(Config.getParam("defaultUser", "coin"));
        exp         =   Integer.parseInt(Config.getParam("defaultUser", "exp"));
        timeLogin   =   utilities.time.UtilTime.getTimeNow();
        helpFood    =   Integer.parseInt(Config.getParam("defaultUser", "helpFood"));
        avata       =   uAvata;
        name        =   uName;
        helpDay     =   Integer.parseInt(Config.getParam("defaultUser", "helpDay"));
    }

    public Map<String, String> getDefaultData() {
        Map<String, String> data = new HashMap<String, String>();

        data.put(ShareMacros.COTES, cotes);
        data.put(ShareMacros.FRIENDS, friends);
        data.put(ShareMacros.FISH, String.valueOf(fish));
        data.put(ShareMacros.GOLD, String.valueOf(gold));
        data.put(ShareMacros.COIN, String.valueOf(coin));
        data.put(ShareMacros.EXP, String.valueOf(exp));
        data.put(ShareMacros.TIMELOGIN, String.valueOf(timeLogin));
        data.put(ShareMacros.LEVEL, String.valueOf(level));
        data.put(ShareMacros.USER_AVATA, avata);
        data.put(ShareMacros.USER_NAME, name);
        data.put(ShareMacros.USER_HELPFOOD, String.valueOf(helpFood));
        data.put(ShareMacros.USER_HELPDAY, String.valueOf(helpDay));

        return data;
    }
}
